package org.ascollada.core
{
	import flash.errors.IllegalOperationError;
	import org.ascollada.core.ns.collada;
	
	/**
	 * Introduction 
	 * Describes the visual shape and appearance of an object in a scene. 
	 * 
	 * Concepts 
	 * The <geometry> element categorizes the declaration of geometric information. Geometry is a branch of 
	 * mathematics that deals with the measurement, properties, and relationships of points, lines, angles, 
	 * surfaces, and solids. The <geometry> element contains a declaration of a mesh, convex mesh, or spline. 
	 * There are many forms of geometric description. Computer graphics hardware has been normalized, 
	 * primarily, to accept vertex position information with varying degrees of attribution (color, normals, etc.). 
	 * Geometric descriptions provide this vertex data with relative directness or efficiency. Some of the more 
	 * common forms of geometry are: 
	 * B-Spline 
	 * Bézier 
	 * Mesh 
	 * NURBS 
	 * Patch 
	 * This is by no means an exhaustive list. Currently, COLLADA supports only polygonal meshes and splines. 
	 */ 
	public class DaeGeometry extends DaeElement
	{
		use namespace collada;
		
		public var type :String;
		public var mesh :DaeMesh;
		/**
		 * 
		 */ 
		public function DaeGeometry(document:DaeDocument, element:XML=null)
		{
			super(document, element);
		}
		
		/**
		 * 
		 */ 
		public override function read(element:XML):void
		{
			super.read(element);
			
			if(element.mesh[0])
			{
				this.type = "mesh";
				this.mesh = new DaeMesh(this.document, element.mesh[0]);
			}
			else if(element.convex_mesh[0])
			{
				this.type = "convex_mesh";
			}
			else if(element.spline[0])
			{
				this.type = "spline";
			}
			else
			{
				throw new IllegalOperationError("Expected one of <mesh>, <convex_mesh> or <spline>!");
			}
		}
	}
}